package com.miniot.environment.config;


import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.miniot.business.base.id.IdGenerate;
import com.miniot.business.database.datasource.BaseMybatisConfiguration;
import com.miniot.business.database.datasource.MyMetaObjectHandler;
import com.miniot.business.database.properties.DatabaseProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;


/**
 * 配置一些mybatis plus的拦截器和常用配置
 *
 * @author mikelei
 * @since 2022-10-26
 */
@Configuration
@Slf4j
public class ServerMybatisAutoConfiguration extends BaseMybatisConfiguration {
    public ServerMybatisAutoConfiguration(DatabaseProperties databaseProperties) {
        super(databaseProperties);
    }

    @Bean({"myMetaObjectHandler"})
    public MetaObjectHandler getMyMetaObjectHandler(@Qualifier("snowflakeIdGenerate") IdGenerate<Long> idGenerate) {
        return new MyMetaObjectHandler(idGenerate);
    }
}